package cc.atliberty.client;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/RequestClient")
public class RequestClient extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.print("当前URL为： " + request.getRequestURL() + "<br/>");
        out.print("当前URL为： " + request.getRequestURI() + "<br/>");
        out.print("请求携带参数为： " + request.getQueryString() + "<br/>");
        out.print("客户端IP为： " + request.getRemoteAddr() + "<br/>");
        out.print("客户端主机为： " + request.getRemoteHost() + "<br/>");
        out.print("客户端端口为： " + request.getRemotePort() + "<br/>");
        out.print("服务器IP为： " + request.getLocalAddr() + "<br/>");
        out.print("服务器主机名为： " + request.getLocalName() + "<br/>");
        out.print("返回请求头的方法为： " + request.getMethod() + "<br/>");
    }
}
